//封装表格自适应高度的函数
import { ref } from 'vue'
export function useTableHeight(tableRef: any) {
    //定义一个响应式 表格的高度
    const tableHeight = ref(200)
    //提取设置表格宽度的逻辑
    const setTableHeight = () => {
        tableHeight.value = window.innerHeight - tableRef.value.getBoundingClientRect().top - 40
    }
    //设置响应式高度的函数
    const getTableHeight = () => {
        window.addEventListener('resize', setTableHeight)
    }
    //卸载监听事件
    const removeResize = () => {
        window.removeEventListener('resize', setTableHeight)
    }
    //返回需要暴露的数据和函数
    return {
        tableHeight,
        setTableHeight,
        getTableHeight,
        removeResize
    }
}
